

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=dark>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/my-blog/img/fluid.png">
  <link rel="icon" href="/my-blog/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="木舟">
  <meta name="keywords" content="python Vue Test 测试开发 自动化测试">
  
    <meta name="description" content="前言要做自动化测试, 肯定得有一个成果输出 那么报告肯定就是对这次成果一个很好的展示 所以, 我们必须得学习allure. Allure是一个独立的报告插件，生成美观易读的报告，目前支持语言：Java, PHP, Ruby, Python, Scala, C# 安装 下载allure文件包，解压至任意目录 将allure解压目录的bin目录添加至环境变量path中 验证：allure –versi">
<meta property="og:type" content="article">
<meta property="og:title" content="pytest必学之allure报告">
<meta property="og:url" content="https://walker_kwu.gitee.io/my-blog/2023/05/20/autoTest/pytest%E5%BF%85%E5%AD%A6%E4%B9%8Ballure%E6%8A%A5%E5%91%8A/">
<meta property="og:site_name" content="My Blog">
<meta property="og:description" content="前言要做自动化测试, 肯定得有一个成果输出 那么报告肯定就是对这次成果一个很好的展示 所以, 我们必须得学习allure. Allure是一个独立的报告插件，生成美观易读的报告，目前支持语言：Java, PHP, Ruby, Python, Scala, C# 安装 下载allure文件包，解压至任意目录 将allure解压目录的bin目录添加至环境变量path中 验证：allure –versi">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://walker_kwu.gitee.io/my-blog/img/allure/allure%E6%B3%A8%E8%A7%A3.png">
<meta property="og:image" content="https://walker_kwu.gitee.io/my-blog/img/allure/behavior.png">
<meta property="og:image" content="https://walker_kwu.gitee.io/my-blog/img/allure/Packages.png">
<meta property="og:image" content="https://walker_kwu.gitee.io/my-blog/img/allure/Packages1.png">
<meta property="og:image" content="https://walker_kwu.gitee.io/my-blog/img/allure/Graphs.png">
<meta property="og:image" content="https://walker_kwu.gitee.io/my-blog/img/allure/Step.png">
<meta property="og:image" content="https://walker_kwu.gitee.io/my-blog/img/allure/Status1.png">
<meta property="og:image" content="https://walker_kwu.gitee.io/my-blog/img/allure/Status2.png">
<meta property="article:published_time" content="2023-05-20T08:35:33.000Z">
<meta property="article:modified_time" content="2023-05-23T10:37:53.245Z">
<meta property="article:author" content="木舟">
<meta property="article:tag" content="自动化测试">
<meta property="article:tag" content="测试开发">
<meta property="article:tag" content="自动化测试框架">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://walker_kwu.gitee.io/my-blog/img/allure/allure%E6%B3%A8%E8%A7%A3.png">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>pytest必学之allure报告 - My Blog</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/my-blog/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/my-blog/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/my-blog/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"walker_kwu.gitee.io","root":"/my-blog/","version":"1.9.2","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"left","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/my-blog/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/my-blog/js/utils.js" ></script>
  <script  src="/my-blog/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.2.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/my-blog/">
      <strong>木舟</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/my-blog/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="pytest必学之allure报告"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        木舟
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2023-05-20 16:35" pubdate>
          2023年5月20日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          6.5k 字
        
      </span>
    

    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="padding-left: 2rem; margin-right: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">pytest必学之allure报告</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：2023年5月23日 晚上
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>要做自动化测试, 肯定得有一个成果输出</p>
<p>那么报告肯定就是对这次成果一个很好的展示</p>
<p>所以, 我们必须得学习allure.</p>
<p>Allure是一个独立的报告插件，生成美观易读的报告，目前支持语言：Java, PHP, Ruby, Python, Scala, C#</p>
<h1 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h1><ul>
<li>下载allure文件包，解压至任意目录</li>
<li>将allure解压目录的bin目录添加至环境变量path中</li>
<li>验证：allure –version</li>
<li>python安装allure插件  pip install allure-pytest</li>
</ul>
<h1 id="快速生成报告"><a href="#快速生成报告" class="headerlink" title="快速生成报告"></a>快速生成报告</h1><h2 id="第一步-生成报告数据文件"><a href="#第一步-生成报告数据文件" class="headerlink" title="第一步, 生成报告数据文件"></a>第一步, 生成报告数据文件</h2><p>通过 <code>--alluredir</code> 参数来指定输出的位置, 一般是根据选取根目录下的一个文件夹</p>
<blockquote>
<p>pytest -s -v –alluredir ./report  testcase/test_1.py</p>
</blockquote>
<p>这个时候, 会在根目录下的 <code>report</code> 文件夹中, 生成一些json文件, 这就是报告的数据文件</p>
<p>allure会根据这些文件来生成对应的html</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs sh">├─ report<br>│  ├─ 555ca79d-db01-4648-9c1e-94f610d1885d-container.json<br>│  ├─ b189fe57-b8bd-401d-843c-fae519e0b708-container.json<br>│  ├─ f5e915bf-b45f-444b-ab1b-01530c10fb4a-result.json<br>│  └─ ff8851fd-5e6e-4c17-8180-e031d0363639-result.json<br></code></pre></td></tr></table></figure>

<h2 id="第二步-可以通过serve-启动服务-在线浏览报告"><a href="#第二步-可以通过serve-启动服务-在线浏览报告" class="headerlink" title="第二步, 可以通过serve 启动服务, 在线浏览报告"></a>第二步, 可以通过serve 启动服务, 在线浏览报告</h2><blockquote>
<p>allure serve ./report</p>
</blockquote>
<p>运行成功后, 会开启一个当前ip+端口的服务</p>
<p>访问这个地址, 就可以看到allure在线报告</p>
<p>比如: <code>http://xx:xxx/index.html</code></p>
<h2 id="第三步-生成html报告文件"><a href="#第三步-生成html报告文件" class="headerlink" title="第三步, 生成html报告文件"></a>第三步, 生成html报告文件</h2><p>生成后的文件, 就可以当作附件用来给领导发送邮件咯</p>
<blockquote>
<p>allure generate [运行结果目录] -o [报告存放目录] -c<br>allure generate ./report -o ./report_html -c</p>
</blockquote>
<p><code>./report</code> 就是我们用pytest运行结束后生成的allure数据文件<br><code>./report_html</code> 就是我们用allure生成的html文件存放路径, 这个文件夹中会包含 <strong>js/css/html/json</strong></p>
<p>换句话说, 生成后, 直接压缩 <code>./report_html</code> 后发出去即可</p>
<h1 id="allure左侧菜单介绍"><a href="#allure左侧菜单介绍" class="headerlink" title="allure左侧菜单介绍"></a>allure左侧菜单介绍</h1><p>1.Overview: 整体数据显示。</p>
<p>2.Suites: 用例集合,按照套件和类分组的已执行测试的标准结构表示形式。</p>
<p>3.Behaviors: 对于行为驱动的方法，此选项卡根据Epic、Feature和Story标记对测试结果进行分组。</p>
<p>4.Categories: “类别”选项卡提供了创建自定义缺陷分类以应用测试结果的方法。</p>
<p>5.Graphs: 用图表显示测试数据中收集的不同统计数据，状态分解或严重性和持续时间图。</p>
<p>6.Packages: 软件包选项卡表示测试结果的树状布局，按不同的包名分组。</p>
<p>7.Timeline: 时间轴选项卡可视化测试执行的回顾，allure适配器收集测试的精确时间，在这个选项卡上，它们相应地按照顺序或并行的时间结构排列。</p>
<h1 id="allure注解说明-以及对应用法"><a href="#allure注解说明-以及对应用法" class="headerlink" title="allure注解说明, 以及对应用法"></a>allure注解说明, 以及对应用法</h1><p><img src="/my-blog/img/allure/allure%E6%B3%A8%E8%A7%A3.png" srcset="/my-blog/img/loading.gif" lazyload></p>
<h2 id="epic-feature-story"><a href="#epic-feature-story" class="headerlink" title="epic/feature/story"></a>epic/feature/story</h2><p>没接触过 <strong>用户故事</strong> 之类的需求说法的同学, 也许会很懵</p>
<p>实际上, 你可以把它们理解为 <strong>定义层级</strong></p>
<ul>
<li>epic: 第一级</li>
<li>feature: 第二级</li>
<li>story: 第三级</li>
</ul>
<p>testcase/test_1.py</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">import</span> allure<br><br><span class="hljs-meta">@allure.epic(<span class="hljs-params"><span class="hljs-string">&quot;第一级1&quot;</span></span>)</span><br><span class="hljs-meta">@allure.feature(<span class="hljs-params"><span class="hljs-string">&quot;第二级第一个用例集合&quot;</span></span>)</span><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase1</span>():<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_a&quot;</span>)<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_b</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_b&quot;</span>)<br><br><br><span class="hljs-meta">@allure.epic(<span class="hljs-params"><span class="hljs-string">&quot;第一级1&quot;</span></span>)</span><br><span class="hljs-meta">@allure.feature(<span class="hljs-params"><span class="hljs-string">&quot;第二级第二个用例集合&quot;</span></span>)</span><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase2</span>():<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_a&quot;</span>)<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_b</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_b&quot;</span>)<br><br><br><span class="hljs-meta">@allure.epic(<span class="hljs-params"><span class="hljs-string">&quot;第一级2&quot;</span></span>)</span><br><span class="hljs-meta">@allure.feature(<span class="hljs-params"><span class="hljs-string">&quot;第二级第一个用例集合&quot;</span></span>)</span><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase3</span>():<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_a&quot;</span>)<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_b</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_b&quot;</span>)<br><br><span class="hljs-meta">@allure.epic(<span class="hljs-params"><span class="hljs-string">&quot;第一级2&quot;</span></span>)</span><br><span class="hljs-meta">@allure.feature(<span class="hljs-params"><span class="hljs-string">&quot;第二级第二个用例集合&quot;</span></span>)</span><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase4</span>():<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_a&quot;</span>)<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_b</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_b&quot;</span>)<br></code></pre></td></tr></table></figure>

<blockquote>
<p>pytest -s -v –alluredir ./report  testcase/test_1.py<br>allure serve ./report</p>
</blockquote>
<p>然后我们通过左侧菜单 [Behaviors] 进入</p>
<p><img src="/my-blog/img/allure/behavior.png" srcset="/my-blog/img/loading.gif" lazyload></p>
<h2 id="title-description"><a href="#title-description" class="headerlink" title="title/description"></a>title/description</h2><p><code>title</code> 可以修改测试用例本身的名字<br><code>description</code> 可以为测试用例增加描述</p>
<p>testcase/test_1.py:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">import</span> allure<br><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase1</span>():<br><br><span class="hljs-meta">    @allure.title(<span class="hljs-params"><span class="hljs-string">&quot;这是test_a用例&quot;</span></span>)</span><br><span class="hljs-meta">    @allure.description(<span class="hljs-params"><span class="hljs-string">&quot;用来打印test_a&quot;</span></span>)</span><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_a&quot;</span>)<br><br><span class="hljs-meta">    @allure.description(<span class="hljs-params"><span class="hljs-string">&quot;用来打印test_b&quot;</span></span>)</span><br><span class="hljs-meta">    @allure.title(<span class="hljs-params"><span class="hljs-string">&quot;这是test_b用例&quot;</span></span>)</span><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_b</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_b&quot;</span>)<br></code></pre></td></tr></table></figure>

<blockquote>
<p>pytest -s -v –alluredir ./report  testcase/test_1.py<br>allure serve ./report</p>
</blockquote>
<p>然后我们通过左侧菜单 [Behaviors/Packages/Suites] 进入</p>
<p>任意一个都可以, 比如我从 <code>Packages</code> 进去</p>
<p><img src="/my-blog/img/allure/Packages.png" srcset="/my-blog/img/loading.gif" lazyload></p>
<h3 id="顺带说明"><a href="#顺带说明" class="headerlink" title="顺带说明"></a>顺带说明</h3><p>Packages 是根据文件目录以及用例文件代码结构生成的层级结构</p>
<p><img src="/my-blog/img/allure/Packages1.png" srcset="/my-blog/img/loading.gif" lazyload></p>
<p>至于我说的对不对, 你可以结合我上诉的目录层级以及代码编写来进行验证</p>
<p>或者你可以自己尝试写一下代码来验证</p>
<h3 id="动态生成title和description"><a href="#动态生成title和description" class="headerlink" title="动态生成title和description"></a>动态生成title和description</h3><p>还记得我们的数据驱动吗? <strong>parametrize</strong></p>
<p>你可以发现, 上述的例子, <code>title/description</code>, 通过装饰器的写法, 内容都是一个写死的字符串</p>
<p>但是如果我们使用 <strong>数据驱动</strong> 的方式来设计我们的框架的时候</p>
<p>按照上面这么写, 展示出来的报告是不是都是写死的?</p>
<p>所以, allure显然也考虑到这种情况.</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">import</span> pytest<br><span class="hljs-keyword">import</span> allure<br><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase</span>():<br><br><span class="hljs-meta">    @pytest.mark.parametrize(<span class="hljs-params"><span class="hljs-string">&#x27;data&#x27;</span>, [&#123;<span class="hljs-string">&#x27;name&#x27;</span>: <span class="hljs-string">&#x27;muzhou1&#x27;</span>&#125;, &#123;<span class="hljs-string">&#x27;name&#x27;</span>: <span class="hljs-string">&#x27;muzhou2&#x27;</span>&#125;]</span>)</span><br><span class="hljs-meta">    @allure.title(<span class="hljs-params"><span class="hljs-string">&#x27;&#123;data[name]&#125;&#x27;</span></span>)  </span><span class="hljs-comment"># 获取字典中的key对应的值</span><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self, data</span>):<br>        <span class="hljs-built_in">print</span>(data)<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_a&quot;</span>)<br><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase2</span>():<br><br><span class="hljs-meta">    @pytest.mark.parametrize(<span class="hljs-params"><span class="hljs-string">&#x27;name&#x27;</span>, [<span class="hljs-string">&#x27;muzhou1&#x27;</span>, <span class="hljs-string">&#x27;muzhou2&#x27;</span>]</span>)</span><br><span class="hljs-meta">    @allure.title(<span class="hljs-params"><span class="hljs-string">&#x27;&#123;name&#125;&#x27;</span></span>)  </span><span class="hljs-comment"># 也可以直接使用参数</span><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self, name</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_a&quot;</span>)<br><br><span class="hljs-string">&quot;&quot;&quot;</span><br><span class="hljs-string">这是通过装饰器+模板匹配的写法, 通过这种方式, 可以配合parametrize来进行动态生成title/description</span><br><span class="hljs-string">注意, 匹配的名字要和parametrize注入的参数名一致</span><br><span class="hljs-string">&quot;&quot;&quot;</span><br></code></pre></td></tr></table></figure>

<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">import</span> pytest<br><span class="hljs-keyword">import</span> allure<br><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase</span>():<br><br><span class="hljs-meta">    @pytest.mark.parametrize(<span class="hljs-params"><span class="hljs-string">&#x27;data&#x27;</span>, [&#123;<span class="hljs-string">&#x27;name&#x27;</span>: <span class="hljs-string">&#x27;muzhou1&#x27;</span>&#125;, &#123;<span class="hljs-string">&#x27;name&#x27;</span>: <span class="hljs-string">&#x27;muzhou2&#x27;</span>&#125;]</span>)</span><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self, data</span>):<br>        <span class="hljs-built_in">print</span>(data)<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_a&quot;</span>)<br><br>        <span class="hljs-comment"># 也可以通过这种调用函数的方式</span><br>        allure.dynamic.title(data[<span class="hljs-string">&#x27;name&#x27;</span>])<br></code></pre></td></tr></table></figure>


<h2 id="severity"><a href="#severity" class="headerlink" title="severity"></a>severity</h2><p>用来声明用例的 <strong>严重程度</strong></p>
<p>当然你也可以理解成 <strong>优先级</strong></p>
<p>级别大小, 由高到低, 详见具体说明</p>
<p>1）blocker级别：中断缺陷（客户端程序无响应，无法执行下一步操作）<br>2）critical级别：临界缺陷（功能点缺失）<br>3）normal级别：正常<br>4）minor级别：次要缺陷（界面错误与UI需求不符）<br>5）trivial级别：轻微缺陷（必填项无提示，或者提示不规范）</p>
<p>testcase/test_1.py:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">import</span> allure<br><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase1</span>():<br><br><span class="hljs-meta">    @allure.severity(<span class="hljs-params">allure.severity_level.BLOCKER</span>)</span><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_a&quot;</span>)<br><br><span class="hljs-meta">    @allure.severity(<span class="hljs-params">allure.severity_level.MINOR</span>)</span><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_b</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_b&quot;</span>)<br></code></pre></td></tr></table></figure>

<blockquote>
<p>pytest -s -v –alluredir ./report  testcase/test_1.py<br>allure serve ./report</p>
</blockquote>
<p>然后我们通过左侧菜单 [Graphs] 进入</p>
<p><img src="/my-blog/img/allure/Graphs.png" srcset="/my-blog/img/loading.gif" lazyload></p>
<p>可以从这个地方看到 <code>severity</code> 的执行分布</p>
<p>并且, 你还可以通过pytest命令行 <code>--allure-severities</code> 参数, 来指定运行某个级别的用例</p>
<blockquote>
<p>pytest -s -v –alluredir ./report –allure-severities blocker,minor  testcase/test_1.py</p>
</blockquote>
<h2 id="step"><a href="#step" class="headerlink" title="step"></a>step</h2><p>描述测试步骤</p>
<p>比如有个用例函数中, 我们就可以通过 <code>step</code> 来进行步骤拆分描述</p>
<p><img src="/my-blog/img/allure/Step.png" srcset="/my-blog/img/loading.gif" lazyload></p>
<blockquote>
<p>pytest -s -v –alluredir ./report  testcase/test_1.py<br>allure serve ./report</p>
</blockquote>
<h3 id="第一种用法"><a href="#第一种用法" class="headerlink" title="第一种用法"></a>第一种用法</h3><p>testcase/test_1.py:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">import</span> allure<br><br><span class="hljs-meta">@allure.step(<span class="hljs-params"><span class="hljs-string">&quot;第一个步骤&quot;</span></span>)</span><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">step_1</span>():<br>    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;---------&gt;step1&quot;</span>)<br><br><span class="hljs-meta">@allure.step(<span class="hljs-params"><span class="hljs-string">&quot;第二个步骤&quot;</span></span>)</span><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">step_2</span>():<br>    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;---------&gt;step2&quot;</span>)<br><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase1</span>():<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self</span>):<br>        step_1()  <span class="hljs-comment"># 运行步骤</span><br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_a&quot;</span>)<br>        step_2()<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_b</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_b&quot;</span>)<br><br></code></pre></td></tr></table></figure>

<p>这种用法, 适用于 <strong>逻辑抽离</strong></p>
<p>意思就是, 你认为某个步骤是较为重复的, 那么你就可以把这个步骤抽离出来当作一个<strong>步骤函数</strong></p>
<h3 id="第二种用法"><a href="#第二种用法" class="headerlink" title="第二种用法"></a>第二种用法</h3><p>随写随用, 通过 <code>with allure.step(&quot;xx&quot;):</code></p>
<p>testcase/test_1.py:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">import</span> allure<br><br><span class="hljs-meta">@allure.step(<span class="hljs-params"><span class="hljs-string">&quot;第一个步骤&quot;</span></span>)</span><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">step_1</span>():<br>    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;---------&gt;step1&quot;</span>)<br><br><span class="hljs-meta">@allure.step(<span class="hljs-params"><span class="hljs-string">&quot;第二个步骤&quot;</span></span>)</span><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">step_2</span>():<br>    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;---------&gt;step2&quot;</span>)<br><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase1</span>():<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self</span>):<br>        step_1()  <span class="hljs-comment"># 运行步骤</span><br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_a&quot;</span>)<br>        step_2()<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_b</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-keyword">with</span> allure.step(<span class="hljs-string">&quot;第一个步骤&quot;</span>):<br>            ...<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_b&quot;</span>)<br>        <span class="hljs-keyword">with</span> allure.step(<span class="hljs-string">&quot;第二个步骤&quot;</span>):<br>            ...<br></code></pre></td></tr></table></figure>

<h1 id="更多的状态"><a href="#更多的状态" class="headerlink" title="更多的状态"></a>更多的状态</h1><p>allure实际上可以结合pytest的一些 <code>mark</code> 标记来运行, 也可以根据用例运行的状态来进行标注显示</p>
<p>这里就简单列举一下</p>
<p>testcase/test_1.py</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">import</span> pytest<br><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">TestCase1</span>():<br><br><span class="hljs-meta">    @pytest.mark.skip()</span><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_a</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_a&quot;</span>)<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_b</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_b&quot;</span>)<br><br>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_c</span>(<span class="hljs-params">self</span>):<br>        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;-------&gt;test_1_test_c&quot;</span>)<br>        <span class="hljs-keyword">assert</span> <span class="hljs-number">0</span>  <span class="hljs-comment"># 触发报错</span><br></code></pre></td></tr></table></figure>

<p><img src="/my-blog/img/allure/Status1.png" srcset="/my-blog/img/loading.gif" lazyload><br><img src="/my-blog/img/allure/Status2.png" srcset="/my-blog/img/loading.gif" lazyload></p>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><p>allure这个报告插件, 还有很多很多的功能我们还没介绍</p>
<p>但至少目前来说, 这篇文章介绍的功能, 对于一般的自动化测试框架来说, 是足够用了.</p>
<p>至于其他的功能, 用到的时候再去百度就好了.</p>
<p>使用这类 <strong>辅助插件</strong>, 它们能做的, 只是让我们更加方便实现某些需求.</p>
<p>如何设计好一个高效的自动化框架, 以及能够更好的为使用者避错, 提高易用性, 才是我们封装者首要考虑的事情.</p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/my-blog/categories/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/" class="category-chain-item">自动化测试</a>
  
  
    <span>></span>
    
  <a href="/my-blog/categories/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/pytest/" class="category-chain-item">pytest</a>
  
  

  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/my-blog/tags/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/">#自动化测试</a>
      
        <a href="/my-blog/tags/%E6%B5%8B%E8%AF%95%E5%BC%80%E5%8F%91/">#测试开发</a>
      
        <a href="/my-blog/tags/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E6%A1%86%E6%9E%B6/">#自动化测试框架</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>pytest必学之allure报告</div>
      <div>https://walker_kwu.gitee.io/my-blog/2023/05/20/autoTest/pytest必学之allure报告/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>木舟</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年5月20日</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>更新于</div>
          <div>2023年5月23日</div>
        </div>
      
      <div class="license-meta-item">
        <div>许可协议</div>
        <div>
          
            
            
              <a target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
              <span class="hint--top hint--rounded" aria-label="BY - 署名">
                <i class="iconfont icon-by"></i>
              </span>
              </a>
            
              <a target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
              <span class="hint--top hint--rounded" aria-label="NC - 非商业性使用">
                <i class="iconfont icon-nc"></i>
              </span>
              </a>
            
              <a target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
              <span class="hint--top hint--rounded" aria-label="SA - 相同方式共享">
                <i class="iconfont icon-sa"></i>
              </span>
              </a>
            
          
        </div>
      </div>
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/my-blog/2023/05/12/autoTest/pytest%E5%BF%85%E5%AD%A6%E4%B9%8Bfixture/" title="pytest必学之fixture">
                        <span class="hidden-mobile">pytest必学之fixture</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <span>By 木舟</span> <i class="iconfont icon-love"></i> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/my-blog/js/events.js" ></script>
<script  src="/my-blog/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/my-blog/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      headingSelector : CONFIG.toc.headingSelector || 'h1,h2,h3,h4,h5,h6',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      collapseDepth   : CONFIG.toc.collapseDepth || 0,
      scrollSmooth    : true,
      headingsOffset  : -boardTop
    });
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.10/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/my-blog/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/my-blog/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
